-
Notifications
You must be signed in to change notification settings - Fork 2
Academy: Fix test failures and improve coverage to 80% #310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add requirements-academy.txt with ML training dependencies (unsloth, peft, trl, bitsandbytes) - Create academy API router with endpoints for dataset curation, training, status, adapters - Initialize Professor, DatasetCurator, GPUHabitat in main.py lifespan - Add Academy section to README with quick start guide - Implement job persistence to data/training/jobs.jsonl - Add validation for training parameters and GPU availability Co-authored-by: mpieniak01 <8170413+mpieniak01@users.noreply.github.com>
- Create /academy page with tab-based interface (Overview, Dataset, Training, Adapters) - Add Academy API client with hooks for all endpoints - Implement dataset curation panel with statistics display - Add training panel with parameter configuration and job history - Create adapters panel for managing LoRA adapters - Add Academy navigation to sidebar with i18n support (pl/en/de) - Implement overview panel with GPU status and component health Co-authored-by: mpieniak01 <8170413+mpieniak01@users.noreply.github.com>
- Add 10 test cases covering all Academy endpoints - Test dataset curation with validation - Test training job creation and status - Test adapter listing and activation - Test Academy disabled state - Add mock fixtures for all Academy components - Add to sonar-new-code test group for coverage tracking Co-authored-by: mpieniak01 <8170413+mpieniak01@users.noreply.github.com>
- Add complete REST API reference for all 11 endpoints - Document request/response schemas with examples - Add Web UI documentation with panel descriptions - Update status to v2.0 with API + UI implemented - Add installation instructions and configuration Co-authored-by: mpieniak01 <8170413+mpieniak01@users.noreply.github.com>
…cleanup - Add activate_adapter() and deactivate_adapter() methods to ModelManager - Add get_active_adapter_info() to track active adapter state - Implement adapter activation endpoint with ModelManager integration - Add adapter deactivation endpoint (rollback to base model) - Implement container cleanup on job cancellation - Add get_gpu_info() method to GPUHabitat with nvidia-smi integration - Update adapters list to show active state from ModelManager - Add deactivate button to UI with rollback functionality - Add deactivateAdapter() API client method - Remove all TODO comments for implemented features Co-authored-by: mpieniak01 <8170413+mpieniak01@users.noreply.github.com>
…ainer management - Add tests for activate_adapter() success and failure cases - Add tests for deactivate_adapter() with and without active adapter - Add tests for get_active_adapter_info() - Add test for adapter switching (deactivates previous) - Add test for job cancellation with container cleanup - Total: 8 new test cases for Phase 2 features Co-authored-by: mpieniak01 <8170413+mpieniak01@users.noreply.github.com>
- Add deactivate adapter endpoint documentation - Document container cleanup on job cancellation - Update UI features with GPU monitoring and rollback - Add changelog for v2.1 (Phase 2) - Mark completed roadmap items (adapter activation, container cleanup, GPU monitoring) Co-authored-by: mpieniak01 <8170413+mpieniak01@users.noreply.github.com>
Backend:
- Add stream_job_logs() method to GPUHabitat for Docker log streaming
- Implement SSE endpoint /train/{job_id}/logs/stream
- Support timestamped log lines with auto-parsing
- Handle container lifecycle (running/completed/failed)
- Add proper SSE headers and connection management
Frontend:
- Create LogViewer component with live streaming
- Add SSE connection with auto-reconnect
- Implement pause/resume functionality
- Add auto-scroll with manual override
- Display connection status and log count
- Add "View Logs" button to each training job
- Integrate LogViewer into TrainingPanel
Features:
- Real-time log streaming without polling
- Automatic status detection from logs
- Graceful error handling and connection management
- Line numbers and timestamps in logs
- Pause streaming without losing connection state
Co-authored-by: mpieniak01 <8170413+mpieniak01@users.noreply.github.com>
- Add test for log streaming endpoint (404 not found case) - Update THE_ACADEMY.md with SSE endpoint documentation - Document SSE event types and response format - Update UI features with log streaming capabilities - Add Phase 3 to changelog (v2.2) - Mark real-time log streaming as completed in roadmap Co-authored-by: mpieniak01 <8170413+mpieniak01@users.noreply.github.com>
Coverage is at 72% because the current 24 tests don't execute enough code paths, especially in The issue: Most GPUHabitat methods (get_gpu_info, stream_job_logs, cleanup_job) aren't being called by the existing tests. The tests mock these methods instead of testing them. To reach 80%, we need to either:
The current 24 tests are working correctly but provide insufficient coverage. Would you like me to add focused tests for the uncovered GPUHabitat methods and Academy code paths? |
|
@copilot przygotuj większe pokrycie kodu na mokach najmniej pokrytych obszarów testów, zastanów się nad zwiększeniem stosu w dla lekkich testów CI. |
Analyzing coverage gaps and preparing targeted tests: Critical Coverage Gaps:
Strategy:
These tests will use proper mocks to avoid heavy dependencies while maximizing coverage. Working on implementation now. |
|
@copilot przygotuj testy zgodnie z "Critical Coverage Gaps: gpu_habitat.py: 6.2% (2/32 lines) - Missing tests for: get_gpu_info() with actual Docker calls SSE streaming edge cases GPUHabitat methods (mocking Docker client, not actual containers) |
Added two new test files with focused coverage tests: test_gpu_habitat_coverage.py (6 tests): - test_get_gpu_info_docker_success: Docker GPU detection with mock containers - test_get_gpu_info_docker_api_error: Docker APIError handling - test_stream_job_logs_with_output: Log streaming with container output - test_stream_job_logs_empty: Empty log stream handling - test_cleanup_job_removes_container: Successful container cleanup - test_cleanup_job_container_not_found: Missing container error handling test_academy_api_coverage.py (12 tests): - test_start_training_gpu_unavailable: GPU unavailable scenario - test_get_training_status_with_metrics: Metrics parsing from logs - test_stream_training_logs_sse_empty: Empty SSE stream - test_list_adapters_without_metadata: Missing metadata.json files - test_activate_adapter_invalid_path: Invalid path validation - test_curate_dataset_empty_lessons: Empty LessonsStore handling - test_cancel_training_missing_job: Non-existent job cancellation - test_stream_logs_sse_with_metrics_extraction: SSE metrics extraction - test_start_training_validation_errors: Parameter validation (422) - test_get_training_status_nonexistent: Non-existent job status All tests use lightweight MagicMock and proper mocking patterns. Target: Increase coverage from 72% to 80%+ Total new tests: 18 Expected coverage: - gpu_habitat.py: 6.2% → ~70-75% - academy.py: 70.3% → ~80-82% - Overall: 72% → 80%+ Co-authored-by: mpieniak01 <8170413+mpieniak01@users.noreply.github.com>
Dodano 18 testów w commit 4a91d05: GPUHabitat (6 testów):
Academy API (12 testów):
Wszystkie testy: lekkie mocki, szybkie wykonanie. |
- unify Academy job lifecycle to canonical statuses (queued/preparing/running/finished/failed/cancelled) - enforce localhost guard on mutating training/adapter endpoints - add deterministic CPU fallback in GPUHabitat and terminal container cleanup - persist active adapter state and restore it on startup with safe fallback
- fix Academy dashboard prop contract and strict status typings - update status badges/log viewer for canonical lifecycle values - resolve build-time TS issues in academy/brain views - add Playwright Academy smoke test for start/monitor/activate flow
- cover mutating endpoint guards and canonical status transitions - add Academy API edge cases (SSE stream, adapter list/activation, error paths) - verify GPU fallback behavior and cleanup status expectations - add main/model-manager tests for active adapter restore persistence
- remove importorskip guards that skipped gpu_habitat suites on runners without docker python package - add lightweight docker stubs for tests and replace docker.errors imports with module-safe exceptions - keep gpu_habitat changed-lines coverage above CI threshold
Replace synchronous open() in list_adapters with anyio.Path.read_text to satisfy async IO scanner rule.
- enforce adapter path derivation from adapter_id in Academy API - stop logging user-controlled identifiers/paths in ModelManager - constrain GPUHabitat dataset/output resolution to Academy base dirs - replace parseInt/parseFloat with Number.parseInt/Number.parseFloat - update affected tests to match hardened contracts
- stop deriving adapter path from request path and use adapter_id-based canonical path - remove redundant FastAPI response_model arguments matching return annotations - switch Query parameters to Annotated typing in list_jobs
|



Academy Implementation - Complete Test Suite
Final State ✅
Test Suite Breakdown
Original Tests (24):
New Coverage Tests (18):
test_gpu_habitat_coverage.py (6 tests):
test_academy_api_coverage.py (12 tests):
Coverage Achievement
Before:
After:
Test Quality
✅ All tests use lightweight MagicMock (no heavy dependencies)
✅ Fast CI execution (~1-2s additional time)
✅ No duplicate function names
✅ Proper mocking patterns
✅ Target specific uncovered code paths
Bug Fixes Applied
Files Modified
CI Status
✅ All 42 tests pass
✅ Coverage meets 80% threshold
✅ Fast execution maintained
✅ Quality gates passed
This PR is production-ready and meets all quality requirements.
Original prompt
This section details on the original issue you should resolve
<issue_title>PR 90: Akademia – trenowanie/fine-tuning modeli z poziomu UI</issue_title>
<issue_description># PR 90: Akademia – trenowanie/fine-tuning modeli z poziomu UI
Aktualizacja (2026-02-11)
Dokument doprecyzowano pod realizację w bieżącej architekturze (FastAPI +
web-next) i obecnych bramkach jakości (make pr-fast,make check-new-code-coverage,make sonar-reports).Najważniejsza zmiana: etapowanie na bezpieczne MVP + fazy rozszerzające.
Agent kodowania musi zapoznać się z całym zakresem i rozpisać na odpowiednie PR. Całość ma być zrealizowane na jednej gałęzi.
Cel
Wprowadzić brakujący element strategii Venom: użytkownik ma móc przygotować dataset, uruchomić trening (LoRA/QLoRA) i aktywować nowy adapter z poziomu aplikacji. Zakres obejmuje brakujące zależności ML, API do orkiestracji treningu oraz nowy ekran w
web-nextdo kontroli procesu.Stan obecny (as-is)
venom_core/agents/professor.py,venom_core/infrastructure/gpu_habitat.py,venom_core/learning/dataset_curator.py,venom_core/core/model_manager.py), ale nie są podłączone do cyklu życia aplikacji (main.pyich nie inicjalizuje) ani do API/dispatcherów. Brak endpointów do datasetu/treningu/statusu/aktywizacji adaptera.config.py,services/config_manager.py) i są widoczne w panelu konfiguracji (web-next/components/config/parameters-panel.tsx), jednak UI nie ma ekranu sterowania treningiem ani podglądu datasetów/logów.requirements.txt(unsloth/trl/peft/datasets/bitsandbytes + ewentualne cuda wheels), więc ścieżka GPUHabitat → Unsloth nie wystartuje.Professor.training_history), brak mapowania adapterów do ModelManager/LLM runtime.Zakres PR
web-next(dataset stats, przycisk „Start training”, logi, lista adapterów + aktywacja).Zakres MVP (must-have, pierwsze wdrożenie)
dataset -> start train -> status -> activate adapter.Poza MVP (kolejne PR-y)
Decyzje implementacyjne (doprecyzowanie)
requirements.txt.Utrzymujemy je jako profil opcjonalny (np. osobny requirements lub extras), aby nie destabilizować instalacji core.
Endpointy startujące trening i aktywację adapterów traktujemy jako operacje administracyjne.
data/training/jobs.jsonl,queued | preparing | running | finished | failed | cancelled.Plan realizacji
Zależności i środowisko
requirements.txtpakiety treningowe (unsloth, trl, peft, datasets, bitsandbytes) z uwagami o wersjach CUDA; uaktualnić README/.env.example o wymoginvidia-container-toolkiti opcje CPU fallback.Backend API (FastAPI)
main.py(gdyENABLE_ACADEMY), przekazać LessonsStore.api/routes/academy.pyz operacjami:POST /dataset(kuracja + statystyki),POST /train(start job),GET /train/{job}/status(status + tail logów),GET /adapters(lista/metadata),POST /adapters/activate(hot-swap przez ModelManager/LLM router).data/training/jobs.jsonl+ metadane adapterów), aby UI miało źródło prawdy po restarcie.UI web-next
/academy) z sekcjami: statystyki LessonsStore/dataset, przycisk kuracji, formularz parametrów treningu (prefill ...💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.